/*
 * WorkerThread.h
 *
 *  Created on: Sep 10, 2011
 *      Author: Gherman Alin
 */

#ifndef WORKER__WORKERTHREAD_H_
#define WORKER__WORKERTHREAD_H_

#include "../Threads/all.h"
#include "Command.h"

namespace Worker {

class WorkerThread: public Threads::Thread {
public:
	WorkerThread();
	virtual ~WorkerThread();

	bool add(Command* command);
	void run();
	void stop();

	bool isRunning();

protected:
	virtual bool execute(Command* command)=0;

private:
	volatile bool running;

	Threads::BlockingQueue<Command*> queue;
};

}

#endif
